﻿using System;
using System.Collections.Generic;
using System.Text;
using JsonSharp;
using Barbar.MapReport.HtmlRender.Handlers;
using JsonSharp.Collections;
using Barbar.MapReport.Common.Drawing.Commands;
using Barbar.MapReport.Common.Drawing;
using Barbar.MapReport.HtmlRender.Operations.Regions;

namespace Barbar.MapReport.HtmlRender {
  internal class FixColorRegionCallbackService : RegionCallbackService {
    internal override JsonValue ProcessCallback(MapCallbackData callbackData) {
      RegionWithFixColorData value = (RegionWithFixColorData)GetValue(callbackData);

      JsonObjects result = new JsonObjects();
      foreach (ColoredRegionList regionList in value.GetValidRegionLists(callbackData.GeoBound, callbackData.ZoomLevel)) {
        PolygonBehavior behavior = null;
        if (!String.IsNullOrEmpty(regionList.ToolTip))
          behavior = new PolygonBehaviorBubble(regionList.ToolTip);
        AppendPolygon(result, regionList, callbackData.ZoomLevel, behavior, regionList.FillColor.Color, regionList.StrokeColor.Color, value.StrokeWeight);
      }
      return result;
    }
  }
}
